
Partial Class Home
    Inherits System.Web.UI.Page
    Dim x As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        chkRemMe.Visible = False
        Session("uid") = ""
        Session("uemail") = ""
        Session("b_id") = ""
        Session("bemail") = ""
        Session("admin") = ""
        Session("type") = ""    ' As "user"/"buyer"/"admin"
        Session("prim") = ""    ' As uid/buyer_id/adminid
        Session("sec") = ""     ' As uemail/bemail/"admin"
        Session("ViewMore") = False
        Session("Go") = False
        Session("start") = 0
        Session("end") = 0
    End Sub

    Protected Sub imgLoginRegUser_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgLoginRegUser.Click
        If txtUid.Text = "" Then
            lblErr.Text = "User Name field is blank!"
            lblErr.Visible = True
            Exit Sub
        ElseIf txtPswd.Text = "" Then
            lblErr.Text = "Password field is blank!"
            lblErr.Visible = True
            Exit Sub
        End If

        Dim str As String
        str = txtUid.Text
        x = str.IndexOf("@")

        Dim a As New Globo
        If x = -1 Then
            a.executesql("select uemail, uid, fname from users where uid = '" & txtUid.Text.Replace("'", "''") & "' and pass = '" & a.oCrypto.EncryptTripleDES(txtPswd.Text, Globo.sEncryptionKey).Replace("'", "''") & "'", False)
        Else
            a.executesql("select uemail, uid, fname from users where uemail = '" & txtUid.Text.Replace("'", "''") & "' and pass = '" & a.oCrypto.EncryptTripleDES(txtPswd.Text, Globo.sEncryptionKey).Replace("'", "''") & "'", False)
        End If

        If Not a.dr.Read Then
            lblErr.Text = "Wrong User name or Password"
            lblErr.Visible = True
            Exit Sub
        Else
            Session("uid") = a.dr(1)
            Session("uemail") = a.dr(0)
            Session("type") = "user"

            Session("prim") = Session("uid")
            Session("sec") = Session("uemail")

            Response.Redirect("UProfile.aspx")
        End If
    End Sub

    Protected Sub imgLoginBuyer_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgLoginBuyer.Click
        If txtUid.Text = "" Then
            lblErr.Text = "User Name field is blank!"
            Exit Sub
        ElseIf txtPswd.Text = "" Then
            lblErr.Text = "Password field is blank!"
            Exit Sub
        End If

        Dim str As String
        str = txtUid.Text
        x = str.IndexOf("@")

        Dim a As New Globo
        If x = -1 Then
            a.executesql("select bemail, buyer_id, buyer_name from buyers where buyer_id = '" & txtUid.Text & "' and bpassword = '" & a.oCrypto.EncryptTripleDES(txtPswd.Text, Globo.sEncryptionKey).Replace("'", "''") & "'", False)
        Else
            a.executesql("select bemail, buyer_id, buyer_name from buyers where bemail = '" & txtUid.Text & "' and bpassword = '" & a.oCrypto.EncryptTripleDES(txtPswd.Text, Globo.sEncryptionKey).Replace("'", "''") & "'", False)
        End If

        If Not a.dr.Read Then
            lblErr.Text = "Wrong User name or Password"
            lblErr.Visible = True
            Exit Sub
        Else
            Session("b_id") = a.dr(1)
            Session("bemail") = a.dr(0)
            Session("type") = "buyer"

            Session("prim") = Session("b_id")
            Session("sec") = Session("bemail")

            Response.Redirect("BProfile.aspx")
        End If
    End Sub

    Protected Sub lnkbtnSignUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnSignUp.Click
        Response.Redirect("SignUp.aspx")
    End Sub

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        'code for disable the cache
        '|||||||||||||||||||||||||||||||||||||||||||||||||||||||
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        '|||||||||||||||||||||||||||||||||||||||||||||||||||||||
    End Sub

    Protected Sub imgLoginGuest_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgLoginGuest.Click
        Session("NRload") = 0
        Session("ntype") = ""
        Response.Redirect("NewsRoom.aspx")
    End Sub

    Protected Sub lnkbtnForgotPswd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkbtnForgotPswd.Click
        Response.Redirect("PasswordRetrieval.aspx")
    End Sub

    Protected Sub btnALogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnALogin.Click
        Response.Redirect("AdminLogin.aspx")
    End Sub

    '_____________________________________________________________________________________________________________
    '*************************************************************************************************************
    Protected Sub lnkAboutUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAboutUs.Click
        Response.Redirect("AboutUs.aspx")
    End Sub

    Protected Sub lnkTermCond_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkTermCond.Click
        Response.Redirect("TermsConditions.aspx")
    End Sub

    Protected Sub lnkContactUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkContactUs.Click
        Response.Redirect("ContactUs.aspx")
    End Sub

    Protected Sub lnkFAQs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFAQs.Click
        Response.Redirect("FAQs.aspx")
    End Sub

    Protected Sub lnkFeedback_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFeedback.Click
        Response.Redirect("Feedback.aspx")
    End Sub
End Class